package NewCoder;

public class BM80 {
    public int maxProfit (int[] prices) {
        // write code here
        int min=Integer.MAX_VALUE;
        int ans=0;
        int[] dp=new int[prices.length];
        for(int i=0;i<prices.length;i++){
            if(prices[i]<min){
                min=prices[i];
            }else if( prices[i]-min>ans){
                ans=prices[i]-min;
            }
        }
        return ans;
    }
}
